#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>

const int N = 1e5 + 5;

int e_cnt, n, m, cnt;
int heads[N], siz[N], fa[N], dep[N], dfn[N];

struct Edge {
  int nxt, v;
} e[N];

struct Tree {
  int val, tag;
} tr[N << 2];

inline int read() {
  int ch = getchar(), res = 0;
  bool flag = false;
  while (!isdigit(ch)) {
    if (ch == '-') flag = true;
    ch = getchar();
  }
  while (isdigit(ch)) { res = res * 10 + ch - '0', ch = getchar(); }
  return flag ? -res : res;
}

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}

inline void pushdown(int x) {
  int ls = x << 1, rs = x << 1 | 1;
  if (tr[x].tag) {
    if (dep[tr[ls].tag] < dep[tr[x].tag])
      tr[ls].val = tr[x].tag, tr[ls].tag = tr[x].tag;
    if (dep[tr[rs].tag] < dep[tr[x].tag])
      tr[rs].val = tr[x].tag, tr[rs].tag = tr[x].tag;
  }
}

void modify(int x, int l, int r, int L, int R, int p) {
  if (L <= l && r <= R) {
    if (dep[p] > dep[tr[x].val]) {
      tr[x].val = p;
      tr[x].tag = p;
    }
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(x);
  if (L <= mid) modify(x << 1, l, mid, L, R, p);
  if (R > mid) modify(x << 1 | 1, mid + 1, r, L, R, p);
}

int query(int x, int l, int r, int p) {
  if (l == r) return tr[x].val;
  int mid = (l + r) >> 1;
  pushdown(x);
  if (p <= mid) return query(x << 1, l, mid, p);
  else
    return query(x << 1 | 1, mid + 1, r, p);
}

void dfs(int x) {
  dfn[x] = ++cnt, siz[x] = 1;
  for (int i = heads[x], v; i; i = e[i].nxt)
    if ((v = e[i].v) != fa[x]) {
      dep[v] = dep[x] + 1, fa[v] = x;
      dfs(v);
      siz[x] += siz[v];
    }
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("P4092 [HEOI2016]树.in", "r", stdin);
  freopen("P4092 [HEOI2016]树.out", "w", stdout);
#endif
#endif

  n = read(), m = read();
  for (int i = 1, u, v; i < n; i++) {
    u = read(), v = read();
    add(u, v);
  }
  fa[1] = 1, dfs(1);
  dep[0] = -0x3f3f3f3f;
  modify(1, 1, n, 1, n, 1);
  char opt[2];
  for (int i = 1, x; i <= m; i++) {
    scanf("%s%d", opt, &x);
    if (opt[0] == 'C') modify(1, 1, n, dfn[x], dfn[x] + siz[x] - 1, x);
    else
      printf("%d\n", query(1, 1, n, dfn[x]));
  }
  return 0;
}